package com.older.wptsb.domain.po;


import lombok.Getter;

@Getter
public enum UserRole {
    ADMIN("admin", "系统管理员"),
    FAMILY("family", "家属"),
    VOLUNTEER("community", "社区管理员"),
    DOCTOR("elder", "老人");

    public static final String ROLE_ADMIN = "admin";
    public static final String ROLE_FAMILY = "family";
    public static final String ROLE_COMMUNITY= "community";
    public static final String ROLE_ELDER = "elder";

    private final String code;
    private final String description;

    UserRole(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static UserRole fromCode(String code) {
        for (UserRole role : UserRole.values()) {
            if (role.getCode().equals(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("未知角色代码: " + code);
    }
}
